

interface USB {
    void openDevice();
    void closeDevice();
}

class Mouse implements USB {
    @Override
    public void openDevice() {
        System.out.println("打开鼠标！！");
    }
    @Override
    public void closeDevice() {
        System.out.println("关闭鼠标！！");
    }
    public void click() {
        System.out.println("点击鼠标！！");
    }
}
class KeyBoard implements USB {
    @Override
    public void openDevice() {
        System.out.println("打开键盘！！");
    }

    @Override
    public void closeDevice() {
        System.out.println("关闭键盘！！");
    }
    public void input() {
        System.out.println("输入数据！！");
    }
}
class Computer {
    public void open() {
        System.out.println("打开电脑！！");
    }
    public void useDevice(USB usb) {
        usb.openDevice();
        if(usb instanceof Mouse) {
            Mouse mouse = (Mouse)usb;
            mouse.click();
        }else if(usb instanceof KeyBoard){
            KeyBoard keyBoard = (KeyBoard)usb;
            keyBoard.input();
        }
        usb.closeDevice();
    }
    public void close() {
        System.out.println("关闭电脑！！");
    }
}
public class test {
    public static void main(String[] args) {
        Computer computer = new Computer();
        computer.open();
        computer.useDevice(new Mouse());
        computer.close();
        computer.open();
        computer.useDevice(new KeyBoard());
        computer.close();
    }

}
